﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用checkbox控制文本框</title>
    <script language="javascript">
        function chkOper(chk){
            var inputs = chk.parentNode.parentNode.cells[1].getElementsByTagName("input");
            var status = chk.checked;
            for(var i = 0,j = inputs.length;i<j;i++){
                inputs[i].disabled = status;
            }
        }
    </script>
</head>
<body>
<table width="500" border="1" cellspacing="1" cellpadding="1">
    <tr>
        <td width="40px" align="center">
            <input type="checkbox" name="checkbox" id="" onclick="chkOper(this)"/></td>
        <td width="230px">
            <input type="text" name="textfield" id="Text1" />
        </td>
        <td width="230px">第一行</td>
    </tr>
    <tr>
        <td align="center"><input type="checkbox" name="checkbox" id="Checkbox1"  onclick="chkOper(this)"/></td>
        <td><input type="text" name="textfield2" id="textfield2" /></td>
        <td>第二行</td>
    </tr>
    <tr>
        <td align="center">
            <input type="checkbox" name="checkbox" id="Checkbox2" 
            onclick="chkOper(this)" />
        </td>
        <td><input type="text" name="textfield3" id="textfield3" /></td>
        <td>第三行</td>
    </tr>
</table>
</body>
</html>